package uns.fit.gis.ui;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;

import uns.fit.gis.MapDrawer;
import uns.fit.gis.i18n.LocaleManager;

public class PreviewPhotoForm extends Form implements CommandListener {
	private byte[] dataImg;
	private Command backCommand = new Command(LocaleManager.getMessage("upload"), Command.OK, 1);
	private Command uploadCommand = new Command(LocaleManager.getMessage("back"), Command.BACK, 1); 
	public PreviewPhotoForm(byte[] dataImg) {
		super(LocaleManager.getMessage("title"));
		this.dataImg = dataImg;
		addCommand(backCommand);
		addCommand(uploadCommand);
		
		setCommandListener(this);
		
		append(Image.createImage(dataImg, 0, dataImg.length));
	}
	
	public void commandAction(Command command, Displayable displayable) {
		if(command == backCommand) {
			MapDrawer.getMidlet().showPhotoForm(dataImg);
		}
		else if(command == uploadCommand) {
			MapDrawer.getMidlet().showVideoCanvas();
		}
	}
}
